package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.Entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName UserController
 * @Description: 修改请联系我，否则请勿随意修改
 * @Author ChenYuan
 * @Date 2021/4/30
 * @Version V1.0
 **/
@Slf4j
@Controller
@RequestMapping("/user")
public class UserController {

    @GetMapping("/info")
    @ResponseBody
    public String getUserInfo(HttpServletRequest request){
        User user = new User();
        user.setUsername("chenyuan");
        user.setSex('男');
        user.setAge(2);
        String userStr = JSON.toJSONString(user);
        String requestURI = request.getRequestURI();
        log.info("url:"+requestURI);
        return userStr;
    }

    @PostMapping("/put")
    @ResponseBody
    public Integer getUserPut(HttpServletRequest request){
        String requestURI = request.getRequestURI();
        log.info("url:"+requestURI);
        return 1;
    }
}
